//
//  FWCNavViewController.swift
//  微博项目001
//
//  Created by 樊武超 on 16/4/8.
//  Copyright © 2016年 樊武超. All rights reserved.
//

import UIKit

class FWCNavViewController: UINavigationController,UIGestureRecognizerDelegate{

    
    override class func initialize(){
    
        UINavigationBar.appearance().tintColor=UIColor.orangeColor()
    
    }
        
    override func viewDidLoad() {
        super.viewDidLoad()

       self.interactivePopGestureRecognizer?.delegate=self
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        if childViewControllers.count>0 {
        
            var backTitle: String="返回"
            if childViewControllers.count == 1 {
             backTitle=childViewControllers.first?.navigationItem.title ?? ""
             }
        viewController.navigationItem.leftBarButtonItem=UIBarButtonItem(imageName: "navigationbar_back_withtext", title: backTitle, target: self, selector: "back")
        
        }
        
        super.pushViewController(viewController, animated: animated)
        
        }
    func back(){
    
        popViewControllerAnimated(true)
    
    }
     func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
        
        return childViewControllers.count != 1
    }
}
